#
#
# def max_subarray(list):
#     '''
#
#     :param list:
#     :return:
#     '''
#     max_sum = list[0]
#
#     for i in range(len(list)):
#         for j in range(i,len(list)):
#             current_sum = 0
#             for k in range(i,j+1):
#                 print('k的值：%s'%k)
#                 current_sum += list[k]
#             print('.'*100)
#             if current_sum > max_sum:
#                 max_sum = current_sum
#     return max_sum
#
# result = max_subarray([1,-2,3,-4,5,-6])
# print(result)



# def max_sublist(list):
#     '''
#
#     :param list:
#     :return:
#     '''
#     max_sum = list[0]
#     index1 = 0
#     index2 = 0
#     for i in range(len(list)):
#         index11 = i
#         for j in range(i,len(list)):
#             sub_sum = 0
#             for k in range(i,j+1):
#                 # print(k)
#                 sub_sum += list[k]
#                 index22 = k
#
#             # print('sub_sum:{}'.format(sub_sum))
#             # print('*'*100)
#             if sub_sum > max_sum:
#                 index1 = index11
#                 index2 = index22
#                 # print(index1,index2)
#                 # print('交换了：{},{}'.format(sub_sum,max_sum))
#                 max_sum = sub_sum
#
#     return max_sum,list[index1:index2+1]
#
# result = max_sublist([i for i in range(10000)])
# print(result)


# import sys
# sys.setrecursionlimit(1000)
#
# def max_add_sub(list,f=0,to=7):
#     '''
#
#     :param list:
#     :param f:
#     :param to:
#     :return:
#     '''
#     if to == f:
#         return list[f]
#
#     middle = (f+to)//2
#     m1 = max_add_sub(list,f,middle)
#     m2 = max_add_sub(list,middle+1,to)
#
#     i, left = list[middle],list[middle]
#     now = list[middle]
#
#     for i in range(middle-1,f+1,-1):
#         now += list[i]
#         left = max(now,left)
#
#     right = list[middle+1]
#     now = list[middle+1]
#     for i in range(middle+2,to+1):
#         now += list[i]
#         right = max(now,right)
#
#     m3 = left + right
#     return max(m1,m2,m3)
#
# result = max_add_sub([1,-2,3,10,2,-4,7,2,-5])
# print(result)